package com.item.controller;


import com.item.domain.EpisodePay;
import com.item.service.EpisodePayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class EpisodePayController {

    @Autowired
    EpisodePayService episodePayService;

    @PostMapping(value = "/episodePay/{limit}/{page}")
    public List<EpisodePay> episodePay(
            @PathVariable(value = "limit", required = false) int limit,
            @PathVariable(value = "page", required = false) int page,
            @RequestBody(required = false) EpisodePay episodePay) {

        List<EpisodePay> episodePays = episodePayService.findAll(limit, page, episodePay);
        return episodePays;
    }

    @PostMapping(value = "/episodePay/add")
    public Integer episodePayAdd(@RequestBody EpisodePay episodePay) {

        int i = episodePayService.add(episodePay);
        return i;
    }

    @PutMapping(value = "/episodePay/update")
    public Integer episodePayUpdate(@RequestBody EpisodePay episodePay) {

        int i = episodePayService.update(episodePay);
        return i;
    }

    @DeleteMapping(value = "/episodePay/{id}")
    public Integer episodePayDelete(@PathVariable(value = "id") int id) {

        int i = episodePayService.delete(id);
        return i;
    }

}
